import { request } from 'umi';
import type { RightsListParams, RightsListItem } from './data';

export async function queryRights(params?: RightsListParams) {
  return request('/api/rights', {
    params,
  });
}

export async function addRights(params: RightsListItem) {
  return request('/api/rights', {
    method: 'POST',
    data: {
      ...params,
      method: 'add',
    },
  });
}

export async function updateRights(params: RightsListItem) {
  return request('/api/rights', {
    method: 'POST',
    data: {
      ...params,
      method: 'update',
    },
  });
}

export async function deleteRights(params: { id: number }) {
  return request('/api/rights', {
    method: 'POST',
    data: {
      ...params,
      method: 'delete',
    },
  });
}
